package com.deepinjava.dbbmlite;

import java.util.List;
import java.util.stream.Collectors;

public class BenchresultTrans {
    private Benchresult result;
    private List<BenchresultItem> resultItems;

    public BenchresultTrans(Benchresult benchresult) {
        this.result = benchresult;
        resultItems = benchresult.getItems();
    }

    public Benchresult getResult() {
        return result;
    }

    public void setResult(Benchresult result) {
        this.result = result;
    }

    public List<BenchresultItem> getResultItems() {
        return resultItems;
    }

    public void setResultItems(List<BenchresultItem> resultItems) {
        this.resultItems = resultItems;
    }

    @Override
    public String toString() {
        return "BenchresultTrans{" +
                "result=" + result +
                ", resultItems=" + resultItems +
                '}';
    }

    public String toJson() {
//        String itemls = resultItems.stream().map(m->toJson()).collect(Collectors.joining(",","",""));

        String itemls = "";
        for (BenchresultItem item : resultItems) {
            itemls = itemls + item.toJson() + ",";
        }
        itemls = itemls.substring(0,itemls.length()-1);

        return "{" +
                "\"result\":" + result.toJson() +
                ", \"resultItems\":[" + itemls +
                "]}";
    }

}
